<%--
  Created by IntelliJ IDEA.
  User: MyUser
  Date: 2025/4/11
  Time: 11:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <!-- 页面元信息 -->
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Bootstrap 5 CSS from jsDelivr CDN -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Bootstrap图标库 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">

    <title>帖子详情 - 社区论坛</title>

    <style>
        /* 自定义样式 */
        body {
            background-color: #f8f9fa;
        }
        .post-container {
            max-width: 800px;
            margin: 2rem auto;
            background: white;
            border-radius: 10px;
            box-shadow: 0 0 15px rgba(0,0,0,0.05);
            overflow: hidden;
        }
        .post-header {
            padding: 1.5rem;
            border-bottom: 1px solid #eee;
        }
        .post-title {
            font-size: 1.8rem;
            margin-bottom: 0.5rem;
            word-break: break-word;
        }
        .post-meta {
            color: #6c757d;
            font-size: 0.9rem;
        }
        .post-author-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            object-fit: cover;
            margin-right: 10px;
        }
        .post-content {
            padding: 1.5rem;
            line-height: 1.7;
            word-break: break-word;
        }
        .post-content img {
            max-width: 100%;
            height: auto;
            border-radius: 5px;
            margin: 1rem 0;
        }
        .post-footer {
            padding: 1rem 1.5rem;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .action-btn {
            background: none;
            border: none;
            color: #6c757d;
            cursor: pointer;
            transition: all 0.2s;
            padding: 0.5rem;
            border-radius: 5px;
        }
        .action-btn:hover {
            background-color: #f8f9fa;
            color: #0d6efd;
        }
        .action-btn.active {
            color: #0d6efd;
        }
        .action-btn i {
            margin-right: 5px;
        }
        .edit-history {
            font-size: 0.85rem;
            color: #6c757d;
        }
        .comments-section {
            max-width: 800px;
            margin: 2rem auto;
            background: white;
            border-radius: 10px;
            box-shadow: 0 0 15px rgba(0,0,0,0.05);
            padding: 1.5rem;
        }
        .comment-form {
            margin-bottom: 2rem;
        }
        .comment-list {
            margin-top: 2rem;
        }
        .comment-item {
            padding: 1rem 0;
            border-bottom: 1px solid #eee;
        }
        .comment-item:last-child {
            border-bottom: none;
        }
        .tag {
            display: inline-block;
            background-color: #e9ecef;
            padding: 0.25rem 0.5rem;
            border-radius: 3px;
            font-size: 0.8rem;
            margin-right: 0.5rem;
            color: #495057;
        }
        .avatar-sm {
            width: 30px;
            height: 30px;
            border-radius: 50%;
        }
    </style>
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
    <div class="container">
        <a class="navbar-brand" href="#">广软课程论坛</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto">
                <li class="nav-item">
                    <a class="nav-link active" href="index.jsp">首页</a>
                </li>
            </ul>
            <form class="d-flex me-2" action="/post/search" method="get">
                <input class="form-control me-2" type="search" name="keyword" placeholder="搜索帖子..." aria-label="Search">
                <button class="btn btn-outline-light" type="submit">搜索</button>
            </form>
            <div class="dropdown">
                <a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser" data-bs-toggle="dropdown">
                    <img src="https://img0.baidu.com/it/u=3985150573,583103601&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500" alt="头像" class="avatar-sm me-2">
                    <span></span>
                </a>
                <ul class="dropdown-menu dropdown-menu-end">
                    <li><a class="dropdown-item" href="PersonInfo.jsp">个人中心</a></li>
                    <li><a class="dropdown-item" href="AddNewPost.jsp">发布新帖</a></li>

                    <li><hr class="dropdown-divider"></li>
                    <li><a class="dropdown-item" href="/admin/dashboard">管理后台</a></li>

                    <li><hr class="dropdown-divider"></li>
                    <li><a class="dropdown-item" href="/logout">退出登录</a></li>
                </ul>
            </div>


            <a href="Login.jsp" class="btn btn-outline-light me-2">登录</a>
            <a href="Register.jsp" class="btn btn-light">注册</a>

        </div>
    </div>
</nav>

<!-- 帖子内容 -->
<div class="container">
    <div class="post-container">
        <!-- 帖子头部 -->
        <div class="post-header">
            <!-- 标签 -->
            <div class="mb-2">
                <span class="tag">技术讨论</span>
                <span class="tag">Bootstrap</span>
            </div>

            <!-- 标题 -->
            <h1 class="post-title">如何使用Bootstrap 5快速搭建响应式网站</h1>

            <!-- 作者信息和发布时间 -->
            <div class="d-flex align-items-center post-meta">
                <img src="https://via.placeholder.com/40" alt="作者头像" class="post-author-avatar">
                <div>
                    <span class="fw-bold">张三</span>
                    <span>发布于 2023-05-15 14:30</span>
                    <span class="edit-history">最后编辑于 2023-05-16 09:15</span>
                </div>
            </div>
        </div>

        <!-- 帖子内容 -->
        <div class="post-content">
            <p>Bootstrap 5是最流行的前端框架之一，它提供了一套完整的工具集，可以帮助开发者快速构建响应式网站。本文将介绍如何使用Bootstrap 5的基本组件和布局系统。</p>

            <h4>1. 安装Bootstrap 5</h4>
            <p>可以通过CDN快速引入Bootstrap 5：</p>
            <pre><code>&lt;!-- CSS --&gt;
&lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"&gt;

&lt;!-- JavaScript --&gt;
&lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"&gt;&lt;/script&gt;</code></pre>

            <h4>2. 使用网格系统</h4>
            <p>Bootstrap的网格系统基于12列布局，可以轻松创建响应式设计：</p>
            <pre><code>&lt;div class="container"&gt;
  &lt;div class="row"&gt;
    &lt;div class="col-md-8"&gt;主内容&lt;/div&gt;
    &lt;div class="col-md-4"&gt;侧边栏&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre>

            <img src="https://pic.rmb.bdstatic.com/bjh/3f147fe6d1/240801/a1eb3b9f42e1dda3d8a8c6da1aaa6293.jpeg" alt="示例图片" class="img-fluid">

            <h4>3. 常用组件</h4>
            <p>Bootstrap提供了丰富的组件，如导航栏、卡片、模态框等，可以直接使用。</p>
        </div>

        <!-- 帖子底部操作区 -->
        <div class="post-footer">
            <div class="post-actions">
                <button class="action-btn like-btn" id="likeBtn">
                    <i class="bi bi-hand-thumbs-up"></i>
                    <span id="likeCount">42</span> 点赞
                </button>
                <button class="action-btn">
                    <i class="bi bi-chat-square-text"></i> 评论
                </button>
                <button class="action-btn">
                    <i class="bi bi-bookmark"></i> 收藏
                </button>
            </div>
            <div class="post-actions">
                <button class="action-btn">
                    <i class="bi bi-share"></i> 分享
                </button>
                <button class="action-btn">
                    <i class="bi bi-flag"></i> 举报
                </button>
            </div>
        </div>
    </div>

    <!-- 评论区 -->
    <div class="comments-section">
        <h4>评论 (3)</h4>

        <!-- 评论表单 -->
        <div class="comment-form">
            <div class="mb-3">
                <textarea class="form-control" rows="3" placeholder="写下你的评论..."></textarea>
            </div>
            <div class="d-flex justify-content-end">
                <button class="btn btn-primary">发表评论</button>
            </div>
        </div>

        <!-- 评论列表 -->
        <div class="comment-list">
            <div class="comment-item">
                <div class="d-flex">
                    <img src="https://via.placeholder.com/40" alt="用户头像" class="rounded-circle me-2" width="40" height="40">
                    <div>
                        <div class="fw-bold">李四</div>
                        <div class="text-muted small mb-2">2023-05-15 15:20</div>
                        <div class="comment-content">感谢分享，Bootstrap确实大大提高了开发效率！</div>
                    </div>
                </div>
            </div>

            <div class="comment-item">
                <div class="d-flex">
                    <img src="https://via.placeholder.com/40" alt="用户头像" class="rounded-circle me-2" width="40" height="40">
                    <div>
                        <div class="fw-bold">王五</div>
                        <div class="text-muted small mb-2">2023-05-15 16:45</div>
                        <div class="comment-content">请问Bootstrap 5和4有什么区别？升级需要注意什么？</div>
                    </div>
                </div>
            </div>

            <div class="comment-item">
                <div class="d-flex">
                    <img src="https://via.placeholder.com/40" alt="用户头像" class="rounded-circle me-2" width="40" height="40">
                    <div>
                        <div class="fw-bold">赵六</div>
                        <div class="text-muted small mb-2">2023-05-16 10:30</div>
                        <div class="comment-content">有没有推荐的Bootstrap 5学习资源？</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 页脚 -->
<footer class="bg-light py-4 mt-5">
    <div class="container text-center text-muted">
        <p>© 2025 广州软件学院课程论坛</p>
    </div>
</footer>

<!-- Bootstrap 5 JS Bundle with Popper from jsDelivr CDN -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

<!-- 页面交互脚本 -->
<script>
    document.addEventListener('DOMContentLoaded', function() {
        // 点赞功能
        const likeBtn = document.getElementById('likeBtn');
        const likeCount = document.getElementById('likeCount');
        let isLiked = false;
        let currentLikes = parseInt(likeCount.textContent);

        likeBtn.addEventListener('click', function() {
            if (isLiked) {
                // 取消点赞
                likeCount.textContent = currentLikes - 1;
                likeBtn.classList.remove('active');
            } else {
                // 点赞
                likeCount.textContent = currentLikes + 1;
                likeBtn.classList.add('active');
            }
            isLiked = !isLiked;
            currentLikes = parseInt(likeCount.textContent);
        });

        // 图片点击预览
        document.querySelectorAll('.post-content img').forEach(img => {
            img.style.cursor = 'pointer';
            img.addEventListener('click', function() {
                // 这里可以添加图片放大预览的功能
                console.log('点击了图片:', this.src);
            });
        });

        // 代码块复制功能
        document.querySelectorAll('pre code').forEach(codeBlock => {
            const pre = codeBlock.parentElement;
            const copyBtn = document.createElement('button');
            copyBtn.className = 'btn btn-sm btn-outline-secondary position-absolute';
            copyBtn.style.top = '0.5rem';
            copyBtn.style.right = '0.5rem';
            copyBtn.innerHTML = '<i class="bi bi-clipboard"></i>';
            copyBtn.title = '复制代码';

            // 添加复制按钮
            pre.style.position = 'relative';
            pre.insertBefore(copyBtn, codeBlock);

            // 复制功能
            copyBtn.addEventListener('click', function() {
                navigator.clipboard.writeText(codeBlock.textContent)
                    .then(() => {
                        copyBtn.innerHTML = '<i class="bi bi-check2"></i>';
                        copyBtn.classList.remove('btn-outline-secondary');
                        copyBtn.classList.add('btn-outline-success');
                        setTimeout(() => {
                            copyBtn.innerHTML = '<i class="bi bi-clipboard"></i>';
                            copyBtn.classList.remove('btn-outline-success');
                            copyBtn.classList.add('btn-outline-secondary');
                        }, 2000);
                    })
                    .catch(err => {
                        console.error('复制失败:', err);
                    });
            });
        });
    });
</script>
</body>
</html>
